﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Compilex.Automata;
namespace Compilex.Lexer.Automata
{
    public class CommentsDFA : DFA
    {
        public CommentsDFA()
        {
            this.StartState = BuildAutomaton();
        }

        private DFAState BuildAutomaton()
        {
            DFAState startState = new DFAState("q0");
            DFAState firstSlash = new DFAState("q1");
            DFAState secondSlash = new DFAState("q2");
            DFAState acceptState = new DFAState("q3", true);

            startState.AddTransition('/', firstSlash);

            firstSlash.AddTransition('/', secondSlash);
            secondSlash.AddTransition(c => c != "\n", secondSlash);
            secondSlash.AddTransition(c => c == "\n", acceptState);

            return startState;
        }
    }
}
